package com.share.two.bio2;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.Socket;

public class ServerHandler implements Runnable{
	
	private Socket socket;
	
	public ServerHandler(Socket socket) {
		super();
		this.socket = socket;
	}

	@Override
	public void run() {
		try {
			Thread.sleep(1000);
			System.out.println("子线程");
			BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
			PrintStream ps = new PrintStream(socket.getOutputStream());
			
			String readLine = br.readLine();
			System.out.println("server接收：  " + readLine);
			String back = new StringBuffer(readLine).reverse().toString();
			ps.println(back);
			System.out.println("server返回： " + back);
			socket.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}

}
